LiveUser_Admin
[ class tree: LiveUser_Admin ] [ index: LiveUser_Admin ] [ all elements ]

Source for file User.php

Documentation is available at User.php

  1. <?php require_once 'index.php'?>
  2. <h3>User</h3>
  3. <h4>for this test to work you need to add a "name" and an "email" field to your auth user table</h4>
  4. <?php
  5. // Add
  6. for ($i = 1; $i < 10; $i++{
  7.     $custom = array(
  8.         'name'  => 'asdf'.$i,
  9.         'email' => 'fleh@example.com'.$i
  10.     );
  11.  
  12.     $user_id $admin->addUser('johndoe' rand()'dummypass'array()$customnull'1');
  13.     if ($user_id === false{
  14.         echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  15.     else {
  16.         echo 'Created User Id <b>' $user_id '</b><br />';
  17.     }
  18. }
  19.  
  20. // Get
  21. // Group of users
  22. echo 'All the users:<br />';
  23. $allUsers $admin->searchUsers();
  24.  
  25. if ($allUsers === false{
  26.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  27. else {
  28.     Var_Dump::display($allUsers);
  29.     echo '<br />';
  30. }
  31.  
  32. $id array_rand($allUsers);
  33. // single user
  34. echo 'This user will be removed:<br />';
  35. $user $admin->getUser($allUsers[$id]['perm_user_id']);
  36. if ($user === false{
  37.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  38. else {
  39.     Var_Dump::display($user);
  40.     echo '<br />';
  41. }
  42.  
  43. // Remove
  44. $removed $admin->removeUser($allUsers[$id]['perm_user_id']);
  45.  
  46. if ($removed === false{
  47.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  48. else {
  49.     echo '<b>' $id '</b> was deleted<br />';
  50.     unset($allUsers[$id]);
  51. }
  52.  
  53. // Update
  54. $id array_rand($allUsers);
  55. $updateUser $allUsers[$id]['perm_user_id'];
  56. $updated $admin->updateUser($updateUser'updated_user'.rand()'foo'array()$custom);
  57. if ($updated === false{
  58.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  59. else {
  60.     echo '<b>' $updateUser '</b> was updated<br />';
  61.     $user $admin->getUser($updateUser);
  62.  
  63.     if ($user === false{
  64.         echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  65.     else {
  66.         Var_Dump::display($user);
  67.         echo '<br />';
  68.     }
  69. }
  70.  
  71. // Get
  72. echo 'All the users:<br />';
  73. $allUsers $admin->searchUsers();
  74. if ($allUsers === false{
  75.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  76. else {
  77.     Var_Dump::display($allUsers);
  78.     echo '<br />';
  79. }
  80.  
  81. $randUser array_rand($allUsers);
  82.  
  83. unset($user);
  84. echo 'Test fetching auth_user_id AND perm_user_id with PERM getUsers()<br />';
  85. echo 'Auth<br />';
  86. $filter = array(array('cond' => '''name' => 'auth_user_id''op' => '=''value' => $allUsers[$randUser]['auth_user_id']'type' => 'text'));
  87. $options = array('with_rights' => true);
  88. $user $admin->auth->getUsers($filter);
  89. if ($user === false{
  90.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  91. else {
  92.     Var_Dump::display($user);
  93.     echo '<br />';
  94. }
  95. unset($user);
  96.  
  97. echo 'Perm<br />';
  98. $filter = array(array('filters' => array('perm_user_id' => '3')));
  99. $user $admin->perm->getUsers($filter);
  100. if ($user === false{
  101.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  102. else {
  103.     Var_Dump::display($user);
  104.     echo '<br />';
  105. }
  106.  
  107. echo '<hr />';

Documentation generated on Mon, 11 Mar 2019 14:00:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.